<?php
class ControllerModuleOceanicCustomFooter extends Controller
{
	protected function index()
	{
		if(!file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/oceanic_custom_footer.tpl'))
		{
			return;
		}

		$setting = $this->config->get('oceanic_custom_footer_module');
		$setting = $setting[0];

		if($setting['status'] == 0) return;

		$this->load->model('tool/image');
		$this->load->language('module/oceanic_custom_footer');
		$language_data = array(
			/* Contact Us */
			'tooltip_phone',
			'tooltip_fax',
			'tooltip_email',
			'tooltip_address',
			'tooltip_skype',
			/* Social Buttons */
			'tooltip_facebook',
			'tooltip_twitter',
			'tooltip_rss',
			'tooltip_dribbble',
			'tooltip_forrst',
			'tooltip_vimeo',
			'tooltip_linkedin',
		);

		for($i = 0; $i < sizeof($language_data); $i++)
		{
        	$this->data[$language_data[$i]] = $this->language->get($language_data[$i]);
		}

		$lang_id = $this->config->get('config_language_id');

		/* Contact Us */
		$contact_us = $setting['rcf_contact_us'];
        $contact_us['header'] 	= html_entity_decode($contact_us['header'][$lang_id]);
        $contact_us['phone'] 	= html_entity_decode($contact_us['phone'][$lang_id]);
        $contact_us['fax'] 		= html_entity_decode($contact_us['fax'][$lang_id]);
        $contact_us['email'] 	= html_entity_decode($contact_us['email'][$lang_id]);
        $contact_us['address'] 	= html_entity_decode($contact_us['address'][$lang_id]);
        $contact_us['skype'] 	= html_entity_decode($contact_us['skype'][$lang_id]);
		$this->data['contact_us'] = $contact_us;

		/* About Us */
		$about_us = $setting['rcf_about_us'];
		$about_us['content'] = html_entity_decode($about_us['content'][$lang_id]);
		$this->data['about_us'] = $about_us;

		/* News */
		$news = $setting['rcf_news'];
		$rows = (isset($news['rows'])) ? $news['rows'] : array();
		$news['rows'] = array();
		for($i = 0; $i < sizeof($rows); $i++)
		{			if(!$rows[$i]['status'])
			{
				continue;
			}

			$rows[$i]['thumb'] = ($rows[$i]['image'] != '') ? $this->model_tool_image->resize($rows[$i]['image'], 48, 48) : '';
			$rows[$i]['title'] = $rows[$i]['title'][$lang_id];

			$news['rows'][] = $rows[$i];
		}
		$count = sizeof($news['rows']) - 1;
		for($i = 0; $i < $count; $i++)
		{			for($j = 0; $j < $count - $i; $j++)
			{
            	if($news['rows'][$j]['sort'] > $news['rows'][$j + 1]['sort'])
            	{                	$t = $news['rows'][$j];
                	$news['rows'][$j] = $news['rows'][$j + 1];
                	$news['rows'][$j + 1] = $t;
            	}
			}
		}
		$this->data['news'] = $news;

		/* Twitter */
		$this->data['twitter'] = $setting['rcf_twitter'];

		/* Social Buttons */
		$this->data['social'] = $setting['rcf_social'];



		$this->template = $this->config->get('config_template') . '/template/module/oceanic_custom_footer.tpl';

		$this->render();
	}
}
?>